package com.ruoyi.carService.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.api.domain.CarMerchant;
import com.ruoyi.system.api.domain.CarServiceType;
import com.ruoyi.system.api.domain.vo.CarServiceDetailVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.api.domain.CarServiceDetail;
import com.ruoyi.carService.service.ICarServiceDetailService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 服务管理Controller
 * 
 * @author ruoyi
 * @date 2024-09-09
 */
@RestController
@RequestMapping("/detail")
public class CarServiceDetailController extends BaseController
{
    @Autowired
    private ICarServiceDetailService carServiceDetailService;

    /**
     * 查询服务管理列表
     */
/*    @RequiresPermissions("carService:detail:list")
    @GetMapping("/list")
    public TableDataInfo list(CarServiceDetail carServiceDetail)
    {
        startPage();
        List<CarServiceDetail> list = carServiceDetailService.selectCarServiceDetailList(carServiceDetail);
        return getDataTable(list);
    }*/

    @RequiresPermissions("carService:detail:list")
    @GetMapping("/list")
    public TableDataInfo list(CarServiceDetailVo carServiceDetailVo)
    {
        startPage();
        List<CarServiceDetailVo> list = carServiceDetailService.selectCarServiceDetailVoList(carServiceDetailVo);
        return getDataTable(list);
    }

    /**
     * 导出服务管理列表
     */
    @RequiresPermissions("carService:detail:export")
    @Log(title = "服务管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CarServiceDetail carServiceDetail)
    {
        List<CarServiceDetail> list = carServiceDetailService.selectCarServiceDetailList(carServiceDetail);
        ExcelUtil<CarServiceDetail> util = new ExcelUtil<CarServiceDetail>(CarServiceDetail.class);
        util.exportExcel(response, list, "服务管理数据");
    }

    /**
     * 获取服务管理详细信息
     */
    @RequiresPermissions("carService:detail:query")
    @GetMapping(value = "/{detailId}")
    public AjaxResult getInfo(@PathVariable("detailId") Long detailId)
    {
        return success(carServiceDetailService.selectCarServiceDetailByDetailId(detailId));
    }

    /**
     * 新增服务管理
     */
    @RequiresPermissions("carService:detail:add")
    @Log(title = "服务管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CarServiceDetail carServiceDetail)
    {
        return toAjax(carServiceDetailService.insertCarServiceDetail(carServiceDetail));
    }

    /**
     * 修改服务管理
     */
    @RequiresPermissions("carService:detail:edit")
    @Log(title = "服务管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CarServiceDetail carServiceDetail)
    {
        return toAjax(carServiceDetailService.updateCarServiceDetail(carServiceDetail));
    }

    /**
     * 删除服务管理
     */
    @RequiresPermissions("carService:detail:remove")
    @Log(title = "服务管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{detailIds}")
    public AjaxResult remove(@PathVariable Long[] detailIds)
    {
        return toAjax(carServiceDetailService.deleteCarServiceDetailByDetailIds(detailIds));
    }

    //查询服务分类
    @GetMapping("/serviceTypeList")
    public List<CarServiceType> serviceTypeList(){
    	return carServiceDetailService.serviceTypeList();
    }

    @GetMapping("/merchantList")
    public List<CarMerchant> merchantList(){
        return carServiceDetailService.merchantList();
    }

}
